﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="MRP.aspx.cs" Inherits="VSM.Business.Purchasing.MRP" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function onCalendarShown(calendarID) {
            var cal = $find("calendarFrom");
            cal._switchMode("months", true);
            if (cal._monthsBody) {
                for (var i = 0; i < cal._monthsBody.rows.length; i++) {
                    var row = cal._monthsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        Sys.UI.DomEvent.addHandler(row.cells[j].firstChild, "click", call);
                    }
                }
            }
        }

        function onCalendarHidden() {
            var cal = $find("calendarFrom");
            if (cal._monthsBody) {
                for (var i = 0; i < cal._monthsBody.rows.length; i++) {
                    var row = cal._monthsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        Sys.UI.DomEvent.removeHandler(row.cells[j].firstChild, "click", call);
                    }
                }
            }
        }

        function call(eventElement) {
            var target = eventElement.target;
            switch (target.mode) {
                case "month":
                    var cal = $find("calendarFrom");
                    cal._visibleDate = target.date;
                    cal.set_selectedDate(target.date);
                    cal._switchMonth(target.date);
                    cal._blur.post(true);
                    cal.raiseDateSelectionChanged();
                    break;
            }
        }


        function onCalendarShownTo(calendarID) {
            var cal = $find("calendarTo");
            cal._switchMode("months", true);
            if (cal._monthsBody) {
                for (var i = 0; i < cal._monthsBody.rows.length; i++) {
                    var row = cal._monthsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        Sys.UI.DomEvent.addHandler(row.cells[j].firstChild, "click", callTo);
                    }
                }
            }
        }

        function onCalendarHiddenTo() {
            var cal = $find("calendarTo");
            if (cal._monthsBody) {
                for (var i = 0; i < cal._monthsBody.rows.length; i++) {
                    var row = cal._monthsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        Sys.UI.DomEvent.removeHandler(row.cells[j].firstChild, "click", callTo);
                    }
                }
            }
        }

        function callTo(eventElement) {
            var target = eventElement.target;
            switch (target.mode) {
                case "month":
                    var cal = $find("calendarTo");
                    cal._visibleDate = target.date;
                    cal.set_selectedDate(target.date);
                    cal._switchMonth(target.date);
                    cal._blur.post(true);
                    cal.raiseDateSelectionChanged();
                    break;
            }
        }

        function OpenDocList() {
            var url = "../../MRPPOList.aspx"
            Main.openCustomDialog(url, 800, 610);
        }

        function OpenMRPList() {
            var url = "../../MRPList.aspx"
            Main.openCustomDialog(url, 800, 610,"MRP List");
        }
    </script>
    <div>
        <asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:HiddenField ID="hdnIsUpdate" runat="server" />
                <asp:HiddenField ID="hdnAbsID" runat="server" />
                <h2>
                    &nbsp;MRP</h2>
                <div style="margin-left: 5px; width: 99%;">
                    <hr />
                    <table border="0" width="100%" style="background-color: #D1D4D8; font-weight: bold;">
                        <tr>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom;">
                                Run Date :</td>
                            <td style="width: 180px">
                                <asp:TextBox ID="txtRunDate" runat="server" Width="150px" Height="21px"></asp:TextBox>
                            </td>
                            <td align="left" style="border-bottom: dotted 1px #808080; vertical-align: bottom;">
                                FC Code:
                            </td>
                            <td>
                                <asp:DropDownList ID="drlForecast" runat="server" Height="21px" Width="150px">
                                </asp:DropDownList>
                            </td>
                            <td align="right">
                                <asp:Button ID="btnMRPList" runat="server" OnClientClick="OpenMRPList(); return false;"
                                    Text="MRP List" Width="80px" />
                            </td>
                        </tr>
                        <tr>
                            <td valign="middle" style="width: 100px; border-bottom: dotted 1px #808080; vertical-align: bottom;">
                                From :</td>
                            <td valign="top" style="width: 70px; white-space: nowrap;">
                                <asp:TextBox ID="txtDateFrom" runat="server" Width="60px" Height="21px">01/2014</asp:TextBox>
                                <cc1:CalendarExtender ID="txtStartMonthYear_CalendarExtender" runat="server" Format="MM/yyyy"
                                    OnClientHidden="onCalendarHidden" OnClientShown="onCalendarShown" PopupButtonID="imgStartMonthYear"
                                    BehaviorID="calendarFrom" TargetControlID="txtDateFrom">
                                </cc1:CalendarExtender>
                                <asp:ImageButton ID="imgStartMonthYear" runat="Server" AlternateText="Click to show calendar"
                                    ImageUrl="~/Images/Calendar_scheduleHS.png" />
                            </td>
                            <td style="width: 120px; border-bottom: dotted 1px #808080; vertical-align: bottom;">
                                Scenario Code:&nbsp;
                            </td>
                            <td colspan="2">
                                <asp:TextBox ID="txtScenarioName" runat="server" Height="21px" Width="147px"></asp:TextBox>
                            </td>
                            </td>
                        </tr>
                        <tr>
                            <td valign="middle" style="width: 100px; border-bottom: dotted 1px #808080; vertical-align: bottom;">
                                To :</td>
                            <td valign="top" style="width: 70px; white-space: nowrap;">
                                <asp:TextBox ID="txtDateTo" runat="server" Width="60px" Height="21px">04/2014</asp:TextBox>
                                <cc1:CalendarExtender ID="Calendarextender1" runat="server" Format="MM/yyyy" OnClientHidden="onCalendarHiddenTo"
                                    OnClientShown="onCalendarShownTo" PopupButtonID="img2" BehaviorID="calendarTo"
                                    TargetControlID="txtDateTo">
                                </cc1:CalendarExtender>
                                <asp:ImageButton ID="img2" runat="Server" AlternateText="Click to show calendar"
                                    ImageUrl="~/Images/Calendar_scheduleHS.png" />
                            </td>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom;">
                                Scenario Name:
                            </td>
                            <td colspan="2">
                                <asp:TextBox ID="txtScenatioDesc" runat="server" Height="21px"
                                    Width="147px"></asp:TextBox>
                                <asp:Button ID="btnRun" runat="server" OnClick="btnRun_Click" Text="Run" Width="80px" />
                            </td>
                        </tr>
                    </table>
                    <hr />
                    <div style="width: 100%">
                        <asp:GridView ID="grvFCT1" CssClass="GridInner" runat="server" Width="100%" BorderColor="White"
                            BackColor="White" AllowSorting="True" AutoGenerateColumns="False" CellPadding="2"
                            HeaderStyle-Height="27px" CellSpacing="2" HeaderStyle-VerticalAlign="Middle"
                            AllowPaging="True" PageSize="20">
                            <PagerSettings Mode="NumericFirstLast" />
                            <PagerStyle BackColor="#70A0D0" Font-Bold="True" HorizontalAlign="Center" VerticalAlign="Middle" />
                            <RowStyle BackColor="#D9E0ED" BorderColor="White" BorderWidth="2px" Height="25px" />
                            <AlternatingRowStyle BackColor="#EEF1F7" BorderColor="White" BorderWidth="2px" />
                            <Columns>
                                <asp:CommandField HeaderText="Action" ShowDeleteButton="True" ShowEditButton="False"
                                    Visible="false" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                    ItemStyle-Width="70px" />
                                <asp:TemplateField HeaderText="#">
                                    <ItemStyle HorizontalAlign="Center" Width="20px" />
                                    <HeaderStyle VerticalAlign="Middle" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblNo" runat="server" Text='<%# Bind("No") %>' BorderStyle="none">
                                        </asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Model">
                                    <ItemStyle HorizontalAlign="Center" Width="100px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblItemCode" runat="server" Text='<%# Bind("ModelName") %>' BorderStyle="none"></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Product">
                                    <ItemStyle HorizontalAlign="left" Width="200px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblItemName" runat="server" Text='<%# Bind("ProductName") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Vendor Code">
                                    <ItemStyle HorizontalAlign="Center" Width="100px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblVendorCode" runat="server" Text='<%# Bind("VendorCode") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Vendor Name">
                                    <ItemStyle HorizontalAlign="Left" Width="200px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblVendorName" runat="server" Text='<%# Bind("VendorName") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="FC">
                                    <ItemStyle HorizontalAlign="Center" Width="80px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblFC" runat="server" Text='<%# Bind("ForeCastQty") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="MinStock">
                                    <ItemStyle HorizontalAlign="Center" Width="100px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblMinStock" runat="server" Text='<%# Bind("MinStock") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="SO Qty">
                                    <ItemStyle HorizontalAlign="Center" Width="100px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblSOQty" runat="server" Text='<%# Bind("SOQty") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="PO Qty">
                                    <ItemStyle HorizontalAlign="Center" Width="100px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblPOQty" runat="server" Text='<%# Bind("POQty") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="InHand">
                                    <ItemStyle HorizontalAlign="Center" Width="100px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblInHand" runat="server" Text='<%# Bind("InHand") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="MRP">
                                    <ItemStyle HorizontalAlign="Center" Width="100px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblMRP" runat="server" Text='<%# Bind("MRP") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <HeaderStyle BackColor="#6095C9"  ForeColor="#ffffff" Font-Overline="False"
                                Height="27px" VerticalAlign="Middle" />
                            <EmptyDataTemplate>
                                <table class="GridInner" style="width: 100%; border-color: White;" border="1" rules="all"
                                    cellspacing="2" cellpadding="2">
                                    <tr valign="middle" style="height: 27px; color: white; text-decoration: none;
                                        background-color: rgb(96, 149, 201);">
                                        <th>
                                            <span>#</span>
                                        </th>
                                        <th>
                                            <span>Item Code</span>
                                        </th>
                                        <th>
                                            <span>Item Name</span>
                                        </th>
                                        <th>
                                            <span>Vendor Code</span>
                                        </th>
                                        <th>
                                            <span>Vendor Name</span>
                                        </th>
                                        <th>
                                            <span>FC</span>
                                        </th>
                                        <th>
                                            <span>MinStock</span>
                                        </th>
                                        <th>
                                            <span>SO Qty</span>
                                        </th>
                                        <th>
                                            <span>PO Qty</span>
                                        </th>
                                        <th>
                                            <span>InHand</span>
                                        </th>
                                        <th>
                                            <span>MRP</span>
                                        </th>
                                    </tr>
                                    <tr>
                                        <td colspan="11">
                                            <span>No Data</span>
                                        </td>
                                    </tr>
                                </table>
                            </EmptyDataTemplate>
                        </asp:GridView>
                    </div>
                    <hr width="100%" />
                </div>
                <table width="100%" border="0">
                    <tr>
                        <td valign="top" style="width: 300px;">
                            <table>
                                <tr>
                                    <td>
                                        <strong>Remarks:</strong>
                                    </td>
                                    <td>
                                        <asp:TextBox runat="server" ID="txtRemarks" Height="71px" TextMode="MultiLine" Width="310px"></asp:TextBox>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div style="margin-left: 5px; width: 99%;">
                                <hr />
                            </div>
                            <table style="width: 100%">
                                <tr>
                                    <td style="width: 220px;">
                                        <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" Width="80px" />
                                    </td>
                                    <td>
                                        <asp:Label ID="lblError" runat="server" Visible="False" Font-Bold="True" ForeColor="Red"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
